<?
/**
* Copyright (c) 2002-2007 BioWare Corp.
* http://www.bigdaddymonitor.org
*
* This file is part of the BigDaddy Monitoring
* program. It is free software distributed under
* the terms of the BSD License. It is ditributed
* in the hopes that it will be useful, but
* WITHOUT ANY WARRANTY; without event the implied
* warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE.
*
* The BSD License is available from:
* http://www.opensource.org/licenses/bsd-license.php
**/

$sEmployee = $_REQUEST['employee'];

$aActiveEmployees = $Employee->GetActiveEmployees();
?>

<form method="get" action="<?=$_SERVER["PHP_SELF"];?>">
<input type="hidden" name="page" value="listusers">
<select name="employee" size=1 class="app_select">

        <?

	foreach($aActiveEmployees as $aEmployee)
	{
	    $sUsername = $aEmployee['username'];
	    $sFullname = $aEmployee['cn'];

	    if ($sUsername == $sEmployee)
	    {
		$s=" selected";
	    }
	    else
	    {
		$s="";
	    }
            ?>
            <option value="<?=$sUsername?>" <?=$s;?>><?=$sFullname?></option>
            <?
        }
	?>
</select>
<input type="submit" value="View Roles" name="submit" class="app_submit" style="float: none">
</form>

<?
if (strlen($sEmployee) > 0)
{
    ?>
<h4>All Roles for <?=$sEmployee?>:</h4>

<table border="0" cellpadding="0" cellspacing="0" class="app_table">
<tr class="app_mainrow">
    <td>
	<b>ID</b>
    </td>
    <td>
	<b>RoleStringID</b>
    </td>
    <td>
	<b>RoleDefinition</b>
    </td>
    <td>
	<b>Start Date</b>
    </td>
    <td>
	<b>End Date</b>
    </td>
    <td>
	<b>Notes</b>
    </td>
    <td>
	<b>Options</b>
    </td>
</tr>

<?
$sUsername = $_REQUEST['employee'];
$aRoles = $RoleAdmin->GetRoleTimelineByUsername($sUsername);

if(is_array($aRoles))
{
    $aRoleInfo = $RoleAdmin->GetRoleInfoByRoleID(array_keys($aRoles));
}
if(is_array($aRoleInfo))
{
    foreach($aRoleInfo as $aInfo)
    {
	$nID = $aInfo['ID'];
	$aRoleInfoHash[$nID] = $aInfo;
    }
}

if(is_array($aRoles))
{
    foreach($aRoles as $nRoleID => $aData)
    {
	$sStart = $aData['startDate'];
	if((int)$sStart == 0)
	{
	    $sStart = '';
	}
	$sEnd = $aData['endDate'];
	if((int)$sEnd == 0)
	{
	    $sEnd = '';
	}
	?>
	<tr valign="top" class="app_row">
	    <td>
		<?=$nRoleID?>
	    </td>
	    <td>
		<?=$aRoleInfoHash[$nRoleID]["roleStringID"]?>
	    </td>
	    <td>
		<a href="<?=$_SERVER["PHP_SELF"];?>?page=editroledef&ID=<?=$aRoleInfoHash[$nRoleID]["roleDefinitionID"];?>"><?=$aRoleInfoHash[$nRoleID]["roleDefinition"];?></a>
	    </td>
	    <td>
		<?=$sStart?>
	    </td>
	    <td>
		<?=$sEnd?>
	    </td>
	    <td>
		<?=$aRoleInfoHash[$nRoleID]["notes"];?>
	    </td>
	    <td>
		<a href="<?=$_SERVER["PHP_SELF"];?>?page=listroleusers&ID=<?=$nRoleID?>">Users</a>
	    </td>
	</tr>
	<?
	
    }
    
}

?>

</table>

<?
}
?>




